package com.bank.controller;

import com.bank.model.User;
import com.bank.service.UserService;
import com.bank.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/vi/pri")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public JsonData login(@RequestParam(value = "mobile") String mobile, @RequestParam(value = "pass_word") String passWord) {
       User user= userService.login(mobile, passWord);
        return user == null ? JsonData.buildError(0, "登陆失败") : JsonData.buildSuccess(1, "成功");
    }
}
